package com.xu.ThrreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 带缓存的线程池
 */
public class ThreadPoolDemo4 {
    public static void main(String[] args) {
        //创建线程池
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 10000; i++) {
            int finalI = i;
            executorService.submit(()->{
                System.out.println("i"+ finalI +"【线程名称】："+Thread.currentThread().getName());
            });
        }
    }
}
